﻿<Window x:Class="StackHashDBConfig.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="StackHash Database Configuration" Height="500" MinHeight="500" Width="700" MinWidth="700" WindowStartupLocation="CenterScreen" ShowInTaskbar="True" Icon="/StackHashDBConfig;component/StackHash.ico" ContentRendered="Window_ContentRendered" Loaded="Window_Loaded" Closing="Window_Closing" Closed="Window_Closed">
    <Window.Resources>
        <ResourceDictionary Source="bug.xaml" />
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="Help" x:Name="commandBindingHelp" Executed="commandBindingHelp_Executed" />
    </Window.CommandBindings>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <Canvas Margin="10" Grid.RowSpan="10" Width="100" Height="100" Background="{StaticResource BugDrawingBrush}" VerticalAlignment="Top" />

        <Rectangle Margin="10" Grid.RowSpan="10" Grid.Column="1" Fill="#CCCCCC" Stroke="#CCCCCC" Width="1" />

        <TextBlock Margin="10" Grid.Column="2" Grid.ColumnSpan="3" FontSize="14" FontWeight="Bold">Database Configuration</TextBlock>
        
        <TextBlock Margin="10,0,10,7" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="3" TextWrapping="Wrap">
            StackHash works with a local copy of the data from your WinQual account. Please choose a 
            folder to store downloaded crash dumps (Cabs) and a database for all other WinQual data.
            If you need a database to get started install
            <Hyperlink Name="hyperlinkInstallExpress" Click="hyperlinkInstallExpress_Click" ToolTip="http://www.microsoft.com/sqlserver/en/us/editions/express.aspx">SQL Server 2008 R2 Express Edition</Hyperlink>.
        </TextBlock>
        
        <TextBlock Margin="10,10,0,3" Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="3" FontWeight="Bold">Cab Folder</TextBlock>

        <Label Margin="5,0,0,0" Grid.Row="3" Grid.Column="2" Target="{Binding ElementName=textBoxCabFolder}">Cab _Folder:</Label>
        <TextBox Margin="3" Grid.Row="3" Grid.Column="3" Name="textBoxCabFolder" TextChanged="textBoxCabFolder_TextChanged" />
        <Button Margin="3,3,10,3" Grid.Row="3" Grid.Column="4" Name="buttonBrowse" Click="buttonBrowse_Click">_Browse...</Button>
        
        <CheckBox Margin="3" Grid.Row="4" Grid.Column="3" Name="checkBoxStoreDatabaseInCabFolder">_Store database files in cab folder</CheckBox>

        <TextBlock Margin="10,20,0,3" Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="3" FontWeight="Bold">Database Settings</TextBlock>

        <Label Margin="5,0,0,0" Grid.Row="6" Grid.Column="2" Target="{Binding ElementName=textBoxProfileName}">Database _Name:</Label>
        <TextBox Margin="3" Grid.Row="6" Grid.Column="3" Name="textBoxDatabaseName" TextChanged="textBoxDatabaseName_TextChanged" />

        <Label Margin="5,0,0,0" Grid.Row="7" Grid.Column="2" Target="{Binding ElementName=comboBoxDatabase}">_Database Type:</Label>
        <ComboBox Margin="3" Grid.Row="7" Grid.Column="3" Name="comboBoxDatabase" ItemsSource="{Binding Candidates}" DisplayMemberPath="TypeDescription" SelectedItem="{Binding SelectedCandidate}" SelectionChanged="comboBoxDatabase_SelectionChanged" />
        <Button Margin="3,3,10,3" Grid.Row="7" Grid.Column="4" Name="buttonRefresh" Click="buttonRefresh_Click">_Refresh</Button>

        <Label Margin="5,0,0,0" Grid.Row="8" Grid.Column="2" Target="{Binding ElementName=listViewInstances}">Database _Instance:</Label>
        <ListView Margin="3,3,3,10" Grid.Row="8" Grid.Column="3" Name="listViewInstances" SelectionMode="Single" ItemsSource="{Binding ElementName=comboBoxDatabase, Path=SelectedItem.Instances}" SelectionChanged="ListView_SelectionChanged">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="125">
                        <GridViewColumnHeader Tag="InstanceName" Content="Instance Name" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding InstanceName}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="125">
                        <GridViewColumnHeader Tag="EditionName" Content="Edition" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding EditionName}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="125">
                        <GridViewColumnHeader Tag="VersionName" Content="Version" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding VersionName}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>

        <Label Margin="5,0,0,10" Grid.Row="9" Grid.Column="2" Target="{Binding ElementName=textBoxConnectionString}">Connection _String:</Label>
        <TextBox Margin="3,3,3,13" Grid.Row="9" Grid.Column="3" Name="textBoxConnectionString" TextChanged="textBoxConnectionString_TextChanged" />
        <Button Margin="3,3,10,13" Grid.Row="9" Grid.Column="4" Name="buttonTestConnectionString" Click="buttonTestConnectionString_Click">_Test</Button>

        <Border Grid.Row="10" Grid.ColumnSpan="5" Style="{StaticResource ButtonBorder}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Button Margin="10,10,3,10" Command="Help">_Help</Button>
                
                <TextBlock Margin="3,10,10,10" Grid.Column="1" VerticalAlignment="Center"><Hyperlink Name="hyperlinkProxySettings" Click="hyperlinkProxySettings_Click">Proxy Settings...</Hyperlink></TextBlock>

                <StackPanel Margin="7" Grid.Column="2" HorizontalAlignment="Right" Orientation="Horizontal">
                    <Button Margin="3" Name="buttonOK" Click="buttonOK_Click" IsDefault="True">OK</Button>
                    <Button Margin="3" Name="buttonCancel" Click="buttonCancel_Click" IsCancel="True">Cancel</Button>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Window>
